﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IISView.ucTools
{
    public partial class ucMyIP : System.Web.UI.UserControl
    {
        private string QQWryPath = System.Web.HttpContext.Current.Server.MapPath(@"App_Data\QQWry.Dat");

        protected void Page_Load(object sender, EventArgs e)
        {
            getIP();
        }

        private void getIP()
        {
            if (Request.QueryString["ip"] == null)
            {
                QT.Tools.Alert("数据错误");
                return;
            }
            string myIP = Request.QueryString["ip"];
            if (string.IsNullOrEmpty(myIP))
            {
                QT.Tools.Alert("数据异常");
                return;
            }
            MyIIS.IPLocation loc = new MyIIS.IPLocation();
            MyIIS.QQWryHelper QQWry = new MyIIS.QQWryHelper(QQWryPath);
            loc = QQWry.GetIPLocation(myIP);
            this.lblIP.Text = myIP;
            this.lblAddress.Text = loc.country + " " + loc.area;
        }
    }
}